package com.easytouch.vmhdl.model;

import com.easytouch.core.Configure;
import com.easytouch.core.DriverThread;
import com.easytouch.core.model.ColumnModel;

import java.util.ArrayList;

/**
 * Created by gulin on 2018/1/17.
 */

public class ManagerAddModel implements IManagerAddModel {

    @Override
    public ArrayList<ColumnModel> getColumnDataByBox(final int pBox)
    {
        ArrayList<ColumnModel> list = new ArrayList<>();
        if(DriverThread.getInstance().mRoadInfo.containsKey(pBox))
        {
            ColumnModel[] columnArray = DriverThread.getInstance().mRoadInfo.get(pBox);
            int maxColumn = columnArray.length;
            if(pBox >= 1 && pBox <= 5) //商品柜需要特殊处理下
            {
                String noodleColumnNum = Configure.getNoodleColumnNum();
                try
                {
                    maxColumn = Integer.parseInt(noodleColumnNum);
                }
                catch (NumberFormatException e)
                {

                }
            }
            else if(pBox == 11) //饮料机需要特殊处理下
            {
                String drinkColumnNum = Configure.getDrinkColumnNum();
                try
                {
                    maxColumn = Integer.parseInt(drinkColumnNum);
                }
                catch (NumberFormatException e)
                {

                }
            }
            if(maxColumn > columnArray.length)
                maxColumn = columnArray.length;
            for (int i = 0;i < maxColumn;i++)
            {
                ColumnModel model = columnArray[i];
                list.add(model);
            }
        }
        return list;
    }
}
